//
//  MemoryLayout-Demo.swift
//  Underlying-MemoryManagement
//
//  Created by jianbo.pei on 2023/12/9.
//

import Foundation

/**
 ## 参考链接
 - **[Swift 三、指针 & 内存管理](https://www.jianshu.com/p/c188a9611499)**
 */

func test_MemoryLayout() {
    let size = MemoryLayout<Teacher>.size
    let stride = MemoryLayout<Teacher>.stride
    let alignment = MemoryLayout<Teacher>.alignment
    print("size is         \(size)")
    print("stride is       \(stride)")
    print("alignment is    \(alignment)")
}

//struct Teacher {
//    var age: Int = 18
//}

/**
 size is         8
 stride is       8
 alignment is    8
 */


struct Teacher {
    var age: Int = 18
    var isHead: Bool = false
}

/**
 size is         9
 stride is       16
 alignment is    8
 */
